﻿
//------------------------------------------------------------------------------

using System;
using System.Linq;
using Apps.IDAL;
using Apps.Models;
using System.Data;

namespace Apps.DAL.Sys
{
    public partial class SysUserConfigRepository
    {
        public SysUserConfig GetById(string id, string userId)
        {
           
            return Context.SysUserConfig.SingleOrDefault(a => a.Id == id && a.UserId == userId);

        }

        public override bool Edit(SysUserConfig model)
        {
            string sql = string.Format("update SYSUSERCONFIG set value='{0}' where Id='{1}' and UserId='{2}'", model.Value,model.Id,model.UserId);
            return ExecuteSqlCommand(sql)>0;
        }

        public override bool Create(SysUserConfig model)
        {
            string sql = string.Format("INSERT INTO SYSUSERCONFIG (Id,Name,Value,Type,State,UserId) VALUES('{0}','{1}','{2}','{3}',{4},'{5}')", model.Id, model.Name, model.Value,model.Type,1,model.UserId);
            return ExecuteSqlCommand(sql) > 0;
        }
    }
}
